//------------------------------------------------------------------------------
#include "fontbutton.h"
//------------------------------------------------------------------------------
FontButton::FontButton(QWidget *parent) : QPushButton(parent){
	m_selectedFont = QFont();
	m_fontDialog = 0;

	connect(this, SIGNAL(released()), this, SLOT(mouseReleased()));
}
//------------------------------------------------------------------------------
FontButton::~FontButton(){}
//------------------------------------------------------------------------------
void FontButton::mouseReleased(){
	if(!m_fontDialog){
		m_fontDialog = new QFontDialog(m_selectedFont, this);
		connect(m_fontDialog, SIGNAL(fontSelected(QFont)), this, SLOT(fontSelected(QFont)));
	}

	m_fontDialog->open();
}
//------------------------------------------------------------------------------
void FontButton::fontSelected(const QFont &font){
	m_selectedFont = font;

	this->setText(font.family());

	if(m_fontDialog)
		m_fontDialog->setCurrentFont(font);

	emit selectedFontChanged(m_selectedFont);
}
//------------------------------------------------------------------------------
